﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

using ESOL.Common.Entity;
using ESOL.WinUI.UICommon;
using ESOL.Business.Mst;
using ESOL.Business.Bpt;
using ESOL.WinUI.Sales;
using ESOL.WinUI.MasterData;
using ESOL.Common;
using ESOL.Business.Sales;
using ESOL.Business.Sec;
using System.Configuration;
using ESOL.Common.Schema;

namespace ESOL.WinUI.Bpt
{
    public partial class frmManageDesignTask : BaseForm.frmBaseMdiBusinessForm
    {
        #region Variable
        private BptDrawBlueprintEntity mSelectDrawBlue;
        private BptDrawBlueprintItemEntity mSelectDrawBlueItem;
        #endregion

        #region Constructor
        public frmManageDesignTask()
        {
            InitializeComponent();
        }
        #endregion

        #region Functions

        private void BingCombobox()
        {
            UICommonFunctions.BindComboboxByCommonItem(cmbAppType, "DT", true);
            UICommonFunctions.BindComboboxByCommonItem(cmbState, "DBT", true);
            UICommon.UICommonFunctions.BindGridComboboxByCommonItem(cStatus, "DBT", true);
            UICommon.UICommonFunctions.BindGridComboboxByCommonItem(cApplicationType, "DT", true);
            UICommon.UICommonFunctions.BindGridComboboxByCommonItem(StatusItem, "DBT", true);
            cmbState.SelectedIndex = 1;

            List<MstPersonEntity> listPerson = new List<MstPersonEntity>();
            if (CommonParameter.CurrentUser.PersonEntity == null)
            {
                listPerson = MstPersonBs.GetMstPersonAllList(false);
            }
            else
            {
                MstPersonBs.GetPersonListBySupervisor(CommonParameter.CurrentUser.PersonId, listPerson);
            }
            MstPersonEntity entity = new MstPersonEntity();
            listPerson.Insert(0, entity);
            cmbDrawPerson.DataSource = listPerson;
            cmbDrawPerson.DisplayMember = "NameCn";
            cmbDrawPerson.ValueMember = "PersonId";
        }

        private string GetCondition()
        {
            string condition = "";
            if (string.IsNullOrEmpty(txtCoustom.Text) == false)
            {
                condition += " AND f.CUSTOMER_NAME LIKE '%" + txtCoustom.Text + "%'";
            }
            if (string.IsNullOrEmpty(txtTaskNumber.Text) == false)
            {
                condition += " AND a.TASK_CODE LIKE '%" + txtTaskNumber.Text + "%'";
            }
            if (string.IsNullOrEmpty(txtProAppionCode.Text) == false)
            {
                condition += " AND e.APPLICATION_CODE LIKE '%" + txtProAppionCode.Text + "%'";
            }
            if (string.IsNullOrEmpty(cmbAppType.Text) == false && cmbAppType.SelectedValue != null)
            {
                condition += " AND a.APPLICATION_TYPE = '" + cmbAppType.SelectedValue.ToString() + "'";
            }
            if (string.IsNullOrEmpty(cmbDrawPerson.Text) == false && cmbDrawPerson.SelectedValue != null)//判断是否是管理者，次方法为暂时使用之方法
            {
                condition += " AND a.DRAWING_PERSON =  '" + cmbDrawPerson.SelectedValue.ToString() + "'";
            }
            //else
            //{
            //    if (cmbDrawPerson.Items.Count > 2)
            //    {
            //    }
            //    else
            //    {
            //        string spersonID = ((ESOL.Common.Entity.MstPersonEntity)(cmbDrawPerson.Items[1])).PersonId;
            //        condition += " AND a.DRAWING_PERSON =  '" + spersonID + "'";
            //    }
            //}
            if (string.IsNullOrEmpty(cmbState.Text) == false && cmbState.SelectedValue != null)
            {
                condition += " AND a.STATUS = '" + cmbState.SelectedValue.ToString() + "'";
            }
            if (dtpApplicationDateFrom.EditValue !=null)
            {
                condition += " AND d.APPROVED_DATE >'" + ((DateTime)dtpApplicationDateFrom.EditValue).ToString("yyyy-MM-dd") +  " 00:00:00'";
            }
            if (dtpApplicationDateTo.EditValue!=null)
            {
                condition += " AND d.APPROVED_DATE <'" + ((DateTime)dtpApplicationDateTo.EditValue).ToString("yyyy-MM-dd") + " 23:59:59'";
            }
            if (string.IsNullOrEmpty(txtOutItem.Text) == false)
            {
                condition += " AND j.PRODUCT_SPEC_OUT LIKE '%" + txtOutItem.Text + "%'";
            }
            if (string.IsNullOrEmpty(txtProductCode.Text) == false)
            {
                condition += " AND k.PRODUCT_CODE LIKE '%" + txtProductCode.Text + "%'";
            }
            return condition;
        }

        private void BindDataGrid()
        {
            string condition = GetCondition();
            string rowCount = txtRowCount.Text;
            string orderBy = "TASK_CODE";

            DataTable dt = BptDrawBlueprintBs.GetCustomerByCondition(condition, orderBy, rowCount);
            gvMain.DataSource = dt;
            gvDetail.DataSource = null;
        }

        private void BingDetailGrid(string DrawBuleID)
        {
            if (!DrawBuleID.Equals(""))
            {
                DataTable dt = new DataTable();
                dt = BptDrawBlueprintItemBs.GetDrawBuleItemByID(DrawBuleID);
                gvDetail.DataSource = dt;
            }
        }

        private void checkButtom(string status)
        {
            if (!status.Equals(""))
            {
                switch (status)
                {
                    case "DBT01"://未分配
                        btnNew.Enabled = true;
                        btnModify.Enabled = false;
                        btnApprove.Enabled = false;
                        btnDelete.Enabled = true;
                        btnCommitTask.Enabled = false;
                        btnSubmit.Enabled = false;
                        break;
                    case "DBT02"://制图中
                        btnNew.Enabled = true;
                        btnApprove.Enabled = false;
                        btnDelete.Enabled = true;
                        if (mSelectDrawBlue.ApplicationType == "DT01")//根据任务类型设置按钮状态
                        {
                            btnCommitTask.Enabled = false;
                            btnModify.Enabled = true;
                            btnSubmit.Enabled = true ;
                        }
                        else
                        {
                            btnCommitTask.Enabled = true;
                            btnModify.Enabled = false;
                            btnSubmit.Enabled = false;
                        }
                        break;
                    case "DBT03"://制图完成
                        btnNew.Enabled = false;
                        btnModify.Enabled = false;
                        btnApprove.Enabled = false;
                        btnDelete.Enabled = true;
                        btnCommitTask.Enabled = false;
                        btnSubmit.Enabled = false;
                        break;
                    case "DBT04"://已删除
                        btnNew.Enabled = false;
                        btnModify.Enabled = false;
                        btnApprove.Enabled = false;
                        btnDelete.Enabled = false;
                        btnCommitTask.Enabled = false;
                        btnSubmit.Enabled = false;
                        break;
                    case "DBT05"://待审核
                        btnNew.Enabled = false;
                        btnModify.Enabled = false;
                        btnApprove.Enabled = true;
                        btnDelete.Enabled = true;
                        btnCommitTask.Enabled = false;
                        btnSubmit.Enabled = false;
                        break;
                    case "DBT06"://待测绘
                        btnNew.Enabled = true;
                        btnApprove.Enabled = false;
                        btnDelete.Enabled = true;
                        if (mSelectDrawBlue.ApplicationType == "DT01")//根据任务类型设置按钮状态
                        {
                            btnCommitTask.Enabled = false;
                            btnModify.Enabled = true;
                            btnSubmit.Enabled = true;
                        }
                        else
                        {
                            btnCommitTask.Enabled = true;
                            btnModify.Enabled = false;
                            btnSubmit.Enabled = false;
                        }
                        break;
                }
            }
        }

        private void SendMessage(string sMessageTitle, string sSender, string sMessageBody, string MessageLevel)
        {
            MstMessageEntity message = new MstMessageEntity();
            message.MessageId = Guid.NewGuid().ToString();
            message.MessateTitle = sMessageTitle;
            message.MessageSender = sSender;
            message.MessageBody = sMessageBody;
            message.MessageLevel = MessageLevel;
            message.FormName = "ESOL.WinUI.Bpt.frmDrawBlueprintManage";
            message.MessageDate = DateTime.Now;
            List<MstPersonEntity> toList = new List<MstPersonEntity>();
            if (!string.IsNullOrEmpty(mSelectDrawBlue.ApprovedBy))
            {
                MstPersonEntity person = MstPersonBs.GetMstPersonByID(mSelectDrawBlue.ApprovedBy);
                toList.Add(person);
            }
            else
            {
                toList =MstMessageBs.GetPersonIdByFormAndObject("ESOL.WinUI.Bpt.frmDrawBlueprintManage", "brnApprove",sSender);
            }
            MstMessageBs.SendMessage(message, toList);
        }

        private void SendMessageToManufacture(string sMessageTitle, string sSender, string sMessageBody, string MessageLevel)
        {
            MstMessageEntity message = new MstMessageEntity();
            message.MessageId = Guid.NewGuid().ToString();
            message.MessateTitle = sMessageTitle;
            message.MessageSender = sSender;
            message.MessageBody = sMessageBody;
            message.MessageLevel = MessageLevel;
            message.FormName = "ESOL.WinUI.Manufacture.frmProductPlanManage";
            message.MessageDate = DateTime.Now;//btnModify
            List<MstPersonEntity> toList = SecUserBs.GetPersonIdByFormAndObject("ESOL.WinUI.Manufacture.frmProductPlanManage", "生单", "btnMakeOrder");
            MstMessageBs.SendMessage(message, toList);
        }

        private byte[] FileToByte(string pStrFName)
        {
            FileInfo fi = new FileInfo(pStrFName);
            FileStream fs = fi.OpenRead();
            byte[] bytes = new byte[fs.Length];
            fs.Read(bytes, 0, Convert.ToInt32(fs.Length));
            return bytes;
        }
        #endregion

        #region Event
        protected override void OnShown(EventArgs e)
        {
            dtpApplicationDateFrom.EditValue = DateTime.Now.AddDays(-15);
            BingCombobox();
            cmbDrawPerson.SelectedIndex = 0;
            BindDataGrid();
            base.OnShown(e);
        }

        private DataRow drTaskSelected;
        private void gridView1_RowClick(object sender, DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e)
        {
            drTaskSelected = gridView1.GetDataRow(e.RowHandle);
            mSelectDrawBlue = new BptDrawBlueprintEntity(drTaskSelected);
            checkButtom(mSelectDrawBlue.Status);
            BingDetailGrid(mSelectDrawBlue.DrawBlueprintId);
        }

        private void txtProAppionCode_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            frmMaintainProductPlanApplicationQuery frm = new frmMaintainProductPlanApplicationQuery();
            if (frm.ShowDialog() == DialogResult.OK && frm.SelectedProdPlanApplication != null)
            {
                txtProAppionCode.Text = frm.SelectedProdPlanApplication.ApplicationCode;
                txtProAppionCode.Tag = frm.SelectedProdPlanApplication;
            }
            else
            {
                txtProAppionCode.Text = "";
                txtProAppionCode.Tag = null;
            }
        }

        private void txtCoustom_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            frmMaintainCustomerQuery frm = new frmMaintainCustomerQuery();
            if (frm.ShowDialog() == DialogResult.OK && frm.SelectedCustomer != null)
            {
                txtCoustom.Text = frm.SelectedCustomer.CustomerName;
                txtCoustom.Tag = frm.SelectedCustomer;
            }
            else
            {
                txtCoustom.Text = "";
                txtCoustom.Tag = null;
            }
        }

        protected override void Click_Query()
        {
            BindDataGrid();
        }

        //查看
        protected override void Click_View()
        {
            if (mSelectDrawBlue == null)
            {
                MessageBox.Show("请选择一个制图任务！", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            frmMaintainDesignTask frm = new frmMaintainDesignTask();
            frm.ThisActionType = ActionType.View;
            frm.SelectedBptDrawBlue = mSelectDrawBlue;
            DialogResult dr = frm.ShowDialog();
            if (dr == System.Windows.Forms.DialogResult.OK)
            {
                BindDataGrid();
            }
        }

        //分配任务
        protected override void Click_New()
        {
            if (mSelectDrawBlue == null)
            {
                MessageBox.Show("请选择一个制图任务！", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            frmMaintainDesignTask frm = new frmMaintainDesignTask();
            frm.ThisActionType = ActionType.Modify;
            frm.SelectedBptDrawBlue = mSelectDrawBlue;
            DialogResult dr = frm.ShowDialog();
            if (dr == System.Windows.Forms.DialogResult.OK)
            {
                BindDataGrid();
            }
        }

        //导入
        protected override void Click_Modify()
        {
            if (mSelectDrawBlue == null)
            {
                MessageBox.Show("请选择一个制图任务！", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            frmMaintainTaskImport frm = new frmMaintainTaskImport();
            frm.SelectTaskCode = mSelectDrawBlue.TaskCode;
            DialogResult dr= frm.ShowDialog();
            if (dr == DialogResult.OK)
            {
                BindDataGrid();
            }

        }

        //交图
        protected override void Click_Submit()
        {
            if (mSelectDrawBlue == null)
            {
                MessageBox.Show("请选择一个制图任务！", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (string.IsNullOrEmpty(drTaskSelected["PRODUCT_CODE"].ToString()))
            {
                MessageBox.Show("请先导入图纸！", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            DialogResult dr = MessageBox.Show("是否提交选中制图任务？", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if (dr == DialogResult.No)
            {
                return;
            }
            mSelectDrawBlue.Status = "DBT05";
            mSelectDrawBlue.FinishedDate = DateTime.Now;
            if (BptBlueprintBs.SaveTask(mSelectDrawBlue))
            {
                MessageBox.Show("交图成功！", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                SendMessage("新审核任务", CommonParameter.CurrentUser.PersonId, "有新的制图任务需要审核了；", MessageLevel.ML03.ToString());
                BindDataGrid();
            }
        }

        //提交
        private void btnCommitTask_Click(object sender, EventArgs e)
        {
            if (mSelectDrawBlue == null)
            {
                MessageBox.Show("请选择一个制图任务！", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            DialogResult dr = MessageBox.Show("是否提交选中制图任务？", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if (dr == DialogResult.No)
            {
                return;
            }
            mSelectDrawBlue.Status = "DBT05";
            mSelectDrawBlue.FinishedDate = DateTime.Now;
            if (BptBlueprintBs.SaveTask(mSelectDrawBlue))
            {
                MessageBox.Show("任务提交成功！", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                SendMessage("新审核任务", CommonParameter.CurrentUser.PersonId, "有新的制图任务需要审核了；", MessageLevel.ML03.ToString());
                BindDataGrid();
            }
        }

        //审核
        protected override void Click_Approve()
        {
            if (mSelectDrawBlue == null)
            {
                MessageBox.Show("请选择一个制图任务！", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (!mSelectDrawBlue.ApprovedBy.Equals(""))
            {
                if (mSelectDrawBlue.ApprovedBy != CommonParameter.CurrentUser.PersonId)
                {
                    MessageBox.Show("您未被指定为该任务的审核人！", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
            }

            DialogResult dr = MessageBox.Show("是否审核通过选中的制图任务？", "Question", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
            if (dr == DialogResult.Cancel)
            {
                return;
            }
            if (dr == DialogResult.No)
            {
                mSelectDrawBlue.Status = "DBT02";
                bool result = BptDrawBlueprintBs.UpdateBptDrawBlueprint(mSelectDrawBlue);
                if (result)
                {
                    MessageBox.Show("拒审成功！", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("拒审失败！", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
            }
            else
            {
                try
                {
                    bool bAutoCreateManufactureBomFlag = false;
                    if (ConfigurationManager.AppSettings["AutoCreateManufactureBomFlag"].ToString().Equals("1"))
                    {
                        bAutoCreateManufactureBomFlag = true;
                    }
                    mSelectDrawBlue.Status = "DBT03";
                    mSelectDrawBlue.ApprovedBy = CommonParameter.CurrentUser.PersonId;
                    mSelectDrawBlue.ApprovedDate = DateTime.Now;                    
                    string sMsg = "";
                    bool result = BptDrawBlueprintBs.ApproveBptDrawBlueprint(bAutoCreateManufactureBomFlag,mSelectDrawBlue, out sMsg);
                    if (result)
                    {
                        MessageBox.Show("审核成功！", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        SendMessageToManufacture("新生产任务", Common.CommonParameter.CurrentUser.PersonId, sMsg, MessageLevel.ML03.ToString());
                    }
                    else
                    {
                        MessageBox.Show("审核失败！", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                    if (mSelectDrawBlue.ApplicationType != "DT01")
                    {
                        MessageBox.Show("审核成功！", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                    SalesProdPlanApplicationItemEntity appentity = new SalesProdPlanApplicationItemEntity();
                    BptApplicationItemEntity bptItemEntity = new BptApplicationItemEntity();
                    BptBlueprintEntity blueEntity = new BptBlueprintEntity();
                    blueEntity = BptBlueprintBs.GetbptBlueprinByID(mSelectDrawBlue.BlueprintId);
                    bptItemEntity = BptApplicationItemBs.GetbptApplicationItemByID(mSelectDrawBlue.ApplicationItemId);
                    appentity = SalesProdPlanApplicationItemBs.GetProdPlanApplicationItemByID(bptItemEntity.PlanApplicationItemId);
                    if (appentity == null)
                    {
                        return;
                    }
                    if (blueEntity != null)
                    {
                        appentity.ProductId = blueEntity.ProductId;
                    }
                    SalesProdPlanApplicationItemBs.UpdateSalesProdPlanApplicationItem(appentity);
                    if (blueEntity == null)
                    {
                        BindDataGrid();
                        return;

                    }
                    BindDataGrid();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }

        //编码器
        protected override void Click_Print()
        {
            frmMaintainEncoder frm = new frmMaintainEncoder();
            frm.ThisActionType = ActionType.New;
            DialogResult dr = frm.ShowDialog();
            BindDataGrid();
        }

        //查看图纸明细
        protected override void Click_Import()
        {
            if (mSelectDrawBlue == null)
            {
                MessageBox.Show("请选择一个制图任务！", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (string.IsNullOrEmpty(drTaskSelected["PRODUCT_CODE"].ToString()))
            {
                MessageBox.Show("请先导入图纸！", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            frmMaintainBlueprintDetail frm = new frmMaintainBlueprintDetail();
            frm.SelectDrawBlue = mSelectDrawBlue;
            frm.ShowDialog();
        }

        protected override void Click_Delete()
        {
            if (mSelectDrawBlue == null)
            {
                MessageBox.Show("请选择一个制图任务！", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            DialogResult dr = MessageBox.Show("是否删除选中制图任务？", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if (dr == DialogResult.No)
            {
                return;
            }
            try
            {
                mSelectDrawBlue.Status = "DBT04";
                bool successful = BptDrawBlueprintBs.UpdateBptDrawBlueprint(mSelectDrawBlue);
                if (successful)
                {
                    MessageBox.Show("删除成功！", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    BindDataGrid();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }

        private void gridView1_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
        {
            if (cmbState.SelectedValue.ToString().Equals("DBT01"))
            {
                DataRow dr = gridView1.GetDataRow(e.RowHandle);
                if (string.IsNullOrEmpty(dr["PRODUCT_SPEC_OUT"].ToString()) == false)
                {
                    DataTable dt1 = SalesProdPlanApplicationItemBs.GetDtByContractModel(dr["PRODUCT_SPEC_OUT"].ToString());
                    if (dt1.Rows.Count > 0)
                    {
                        e.Appearance.BackColor = Color.LightSeaGreen;
                    }
                }
            }
        }

        private void gridView1_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
        {

        }

        private void btnUpdateOnePice_Click(object sender, EventArgs e)
        {
            string sFilePath = "";
            OpenFileDialog op = new OpenFileDialog();
            op.Title = "JPG图纸文件选择";
            op.FileName = "";
            op.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyComputer);
            op.Filter = "JPG文件(*.jpg)|*.jpg";
            op.ValidateNames = true;
            op.CheckFileExists = true;
            op.CheckPathExists = true;
            op.Multiselect = true;
            try
            {
                if (op.ShowDialog() == DialogResult.OK)
                {
                    this.Cursor = Cursors.WaitCursor;
                    string[] FileNanmeList = op.FileNames;
                    List<string> IsNullList = new List<string>();
                    if (FileNanmeList.Length > 0)
                    {
                        for (int i = 0; i < FileNanmeList.Length; i++)
                        {
                            sFilePath = FileNanmeList[i];
                            EsolWevServices.EsolService EService = new EsolWevServices.EsolService();
                            if (System.IO.File.Exists(sFilePath))
                            {
                                //string FileName = sFilePath.Substring(sFilePath.LastIndexOf("\\") + 1, 15);
                                string FileName = sFilePath.Substring(sFilePath.LastIndexOf("\\") + 1, sFilePath.LastIndexOf(".") - sFilePath.LastIndexOf("\\") - 1);
                                if (MstProductBs.GetProductByProductCode(FileName) == null)
                                {
                                    IsNullList.Add(sFilePath);
                                    continue;
                                    //MessageBox.Show("找不到与图片文件名对应的物料编码！");
                                    //return;
                                }
                                try
                                {
                                    ///处理上载的文件流信息。 
                                    byte[] b = FileToByte(sFilePath);
                                    ///调用Web   Services的UploadFile方法进行上载文件。
                                    string aaa = EService.UploadFile(b, FileName + ".jpg");
                                }
                                catch (Exception ex)
                                {
                                    MessageBox.Show("上传失败！");
                                    EService.Dispose();
                                    this.Close();
                                    this.Cursor = Cursors.Default;
                                }
                            }
                            EService.Dispose();
                        }
                    }
                    if (IsNullList.Count > 0)
                    {
                        string Notsussice = "";
                        for (int l = 0; l < IsNullList.Count; l++)
                        {
                            Notsussice += IsNullList[l] + ";\n";
                        }
                        MessageBox.Show("没有上传成功的图片明细：\n" + Notsussice, "提示信息");
                        this.Cursor = Cursors.Default;
                    }
                    else
                    {
                        MessageBox.Show("图片更新成功！");
                        this.Cursor = Cursors.Default;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("上传失败！ ");
                this.Cursor = Cursors.Default;
            }
        }

        //private void btnAbandon_Click(object sender, EventArgs e)
        //{
        //    if (mSelectDrawBlue.Status != "DBT03")
        //    {
        //        MessageBox.Show("此任务还未完成！");
        //        return;
        //    }
        //    string appItemId = "";
        //    appItemId = (BptApplicationItemBs.GetbptApplicationItemByID(mSelectDrawBlue.ApplicationItemId)).PlanApplicationItemId;
        //    if (!string.IsNullOrEmpty(appItemId))
        //    {
        //        ProdPlanOrderEntity ppoEntity = new ProdPlanOrderEntity();
        //        ppoEntity = ProdPlanOrderBs.GetProdPlanOrderByAppItemID(appItemId);
        //        List<ProdPlanOrderItemEntity> listOrderItem = new List<ProdPlanOrderItemEntity>();
        //        listOrderItem = ProdPlanOrderItemBs.GetProdPlanOrderItemByOrderID(ppoEntity.PlanOrderId);
        //        if (listOrderItem.Count > 0)
        //        {
        //            frmBlueprintChangesMaintain frm = new frmBlueprintChangesMaintain();
        //            frm.ThisActionType = ActionType.New;
        //            frm.AppPlanItemId = appItemId;
        //            frm.SelectBptDrawBlueprintChanges = new BptDrawBlueprintChangesEntity();
        //            DialogResult result = frm.ShowDialog();
        //            if (result == DialogResult.OK)
        //            {
        //                BindDataGrid();
        //            }
        //        }
        //        else
        //        {
        //            DialogResult result = MessageBox.Show("此任务还未正式生成工令单，是否确定重新修改此任务？", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
        //            if (result == DialogResult.Yes)
        //            {
        //                mSelectDrawBlue.Status = "DBT02";
        //                bool sresult = BptDrawBlueprintBs.UpdateBptDrawBlueprint(mSelectDrawBlue);
        //                if (sresult)
        //                {
        //                    MessageBox.Show("变更成功！");
        //                    BindDataGrid();
        //                }
        //                else
        //                {
        //                    MessageBox.Show("变更失败！");
        //                }

        //            }
        //        }
        //    }
        //    else
        //    {
        //        MessageBox.Show("找不到对应计划单！");
        //    }
        //}
        //private void tsmCopy_Click(object sender, EventArgs e)
        //{
        //    DataRowView dr = (DataRowView)gvMain.SelectedRows[0].DataBoundItem;
        //    string sProductCode = dr["PRODUCT_CODE"].ToString();
        //    if (!string.IsNullOrEmpty(sProductCode))
        //    {
        //        Clipboard.SetText(sProductCode);
        //    }
        //}

        #endregion

    }
}
